package com.craterhill.java.ccp.dao.impl;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public abstract class AbstractDao<T> extends JdbcDaoSupport {

	protected final static String FIELD_STATUS = "status";
	protected final static String FIELD_CREATED_BY = "created_by";
	protected final static String FIELD_MODIFIED_BY = "modified_by";
	protected final static String FIELD_CREATED_DATE = "created_date";
	protected final static String FIELD_MODIFIED_DATE = "modified_date";

	public final static String MONITER_FIELDS = ", obj." + FIELD_STATUS + ", obj." + FIELD_CREATED_BY + ", obj."
			+ FIELD_MODIFIED_BY + ", obj." + FIELD_CREATED_DATE + ", obj." + FIELD_MODIFIED_DATE;

	public AbstractDao(final DataSource dataSource) {
		super.setDataSource(dataSource);
	}

	protected List<T> findMultipleObject(final String query, final RowMapper<T> rowMapper, final Object... filters) {
		return getJdbcTemplate().query(query, filters, rowMapper);
	}
}
